package cn.kinoko.service.common.export;

import cn.kinoko.common.base.model.BaseEnum;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * @author kinoko
 */
public enum ExportTaskStatusEnum implements BaseEnum<String> {

    WAITING("WAITING", "等待"),
    BUILDING("BUILDING", "制作中"),
    FINISHED("FINISHED", "完成"),
    DOWNLOADING("DOWNLOADING", "下载中"),
    FAIL("FAIL", "失败"),
    ;

    private final String code;

    private final String desc;

    ExportTaskStatusEnum(String type, String title) {
        this.code = type;
        this.desc = title;
    }

    @Override
    public String getCode() {
        return code;
    }


    @Override
    public String getDesc() {
        return desc;
    }

    public static ExportTaskStatusEnum getType(String type) {
        for (ExportTaskStatusEnum v : values()) {
            if (Objects.equals(v.getCode(), type)) {
                return v;
            }
        }
        throw new IllegalArgumentException();
    }

    public static boolean isNotExist(String type) {
        for (ExportTaskStatusEnum v : values()) {
            if (Objects.equals(v.getCode(), type)) {
                return false;
            }
        }
        return true;
    }

    public static List<ExportTaskStatusEnum> getList() {
        return Arrays.asList(values());
}

}